package ru.amse.tsyganov.jumleditor.validator;

import java.util.HashSet;
import java.util.Set;

import org.eclipse.swt.graphics.Image;

import ru.amse.tsyganov.jumleditor.view.SelectedItems;

public class Problem {

	private final Image image;

	private final String description;
	
	private final SelectedItems problemPlace;
	
	private final Set<ProblemSelectionListener> problemSelectionListeners = 
		new HashSet<ProblemSelectionListener>();
	
	public Problem(
			String description,
			SelectedItems problemPlace,
			Image image) {
		
		this.problemPlace = problemPlace;
		this.image = image;
		this.description = description;
	}
	
	public final Image getImage() {
		return image;
	}

	public final String getDescription() {
		return description;
	}

	public final SelectedItems getProblemPlace() {
		return problemPlace;
	}
	
	public final boolean addProblemSelectionListener(
			ProblemSelectionListener listener) {
		
		return problemSelectionListeners.add(listener);
	}
	
	public final boolean removeProblemSelectionListener(
			ProblemSelectionListener listener) {
		
		return problemSelectionListeners.remove(listener);
	}
	
	public final void fireProblemSelected() {
		for (ProblemSelectionListener listener : 
			problemSelectionListeners) {
			
			listener.problemSelected(this);
		}
	}
}
